import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    proxy: {
      //"/api": "http://t.weather.itboy.net/",
      //对以/api开头的请求进行代理
      "/api": {
        // 代理的目标地址
        target: "http://localhost:8080/",
        //设置允许跨域
        changeOrigin: true,
        // 路径重写
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
})
